package com.fs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.R;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.fs.domain.CommonUser;
import com.fs.service.ICommonUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客户列表Controller
 *
 * @author zh
 * @date 2024-10-17
 */
@RestController
@RequestMapping("/customer/serve")
public class CommonUserController extends BaseController {
    @Autowired
    private ICommonUserService commonUserService;

    /**
     * 查询客户列表列表
     */
    // @PreAuthorize("@ss.hasPermi('customer:serve:list')")
    @GetMapping("/list")
    public TableDataInfo list(CommonUser commonUser) {
        startPage();
        List<CommonUser> list = commonUserService.selectCommonUserList(commonUser);
        return getDataTable(list);
    }

    /**
     * 获取客户列表详细信息
     */
    // @PreAuthorize("@ss.hasPermi('customer:serve:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(commonUserService.selectCommonUserById(id));
    }

    /**
     * 修改用户冻结状态并添加冻结原因
     */
    // @PreAuthorize("@ss.hasPermi('customer:serve:edit')")
    @PutMapping("/updateFreezeStatusAndReason")
    public AjaxResult update(@RequestBody CommonUser commonUser) {
        return toAjax(commonUserService.updateFreezeStatusAndReason(commonUser));
    }
}
